package com.bjfu.college.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bjfu.college.pojo.UniversityIntentionRecord;
import com.bjfu.college.vo.RecordDetail;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
* @author 87290
* @description 针对表【university_intention_record】的数据库操作Mapper
* @createDate 2023-07-13 17:37:39
* @Entity com.bjfu.college.pojo.UniversityIntentionRecord
*/
@Repository
public interface UniversityIntentionRecordMapper extends BaseMapper<UniversityIntentionRecord> {

    // 根据条件Wrapper进行多表联合查询
    @Select("SELECT  university_intention_record.*, intention_scheme_intention_record.risk,intention_scheme_intention_record.ranking" +
            " FROM intention_scheme_intention_record " +
            "   LEFT JOIN university_intention_record " +
            "     ON intention_scheme_intention_record.record_id = university_intention_record.id " +
            " ${ew.customSqlSegment} ")
    List<RecordDetail> getRecordsByJoin(@Param("ew") Wrapper wrapper);

    // 同样是多表联合查询，只不过返回的是List<Map>
    @Select("SELECT  university_intention_record.*, intention_scheme_intention_record.risk, intention_scheme_intention_record.ranking " +
            " FROM intention_scheme_intention_record " +
            "   LEFT JOIN university_intention_record " +
            "     ON intention_scheme_intention_record.record_id = university_intention_record.id " +
            " ${ew.customSqlSegment} ")
    List<Map<String,Object>> getRecordsMapByJoin(@Param("ew") Wrapper wrapper);

    // 查询所有的专业大类
    @Select("select distinct major_category from university_intention_record")
    List<String> queryAllMajorCategory();

    // 根据条件查询所有的专业小类
    @Select("select distinct major_class from university_intention_record ${ew.customSqlSegment}")
    List<String> queryAllMajorClassFromCategory(@Param("ew") Wrapper wrapper);
}




